/**
 * Created by john on 2018/8/16.
 */
$(function () {
    // "text!com/contact.ejs"
    require([],function () {
        var parent = $(".parent");
        var name = $(".name");

        var partner = $(".partner");
        var born = $(".born");
        var death = $(".death");
        var src = $(".src");
        var desc = $(".desc");
        var level = $(".level");
        var _id = $(".id");
        var minm = $(".minm");
        var order = $(".order");
        $(".btn").on("click",function () {
            if(name.val() == ''){
                alert("姓名不能为空");
                return ;
            }
            var gender  = $(".gender:checked");
            $.ajax({
                type:'get',
                url:'/api/update',
                data:{
                    _id:_id.val(),
                    parent:parent.val() || -1,
                    name:name.val(),
                    gender:gender.val() || '男',
                    partner:partner.val(),
                    born:born.val(),
                    death:death.val(),
                    src:src.val(),
                    desc:desc.val(),
                    level:level.val(),
                    minm:minm.val(),
                    order:order.val()
                },
                success:function (res) {
                    console.log(res);
                    alert("修改成功.");
                }
            })
        });
    });
});